package org.jeecg.modules.product.job.guardian.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.product.job.guardian.entity.TbJobGuardianHeadquarters;
import org.jeecg.modules.product.job.guardian.mapper.TbJobGuardianCertificateMapper;
import org.jeecg.modules.product.job.guardian.mapper.TbJobGuardianHeadquartersMapper;
import org.jeecg.modules.product.job.guardian.mapper.TbJobGuardianWorktypeMapper;
import org.jeecg.modules.product.job.guardian.service.ITbJobGuardianHeadquartersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.Collection;

/**
 * @Description: 企业内监护人
 * @Author: jeecg-boot
 * @Date:   2024-06-19
 * @Version: V1.0
 */
@Service
public class TbJobGuardianHeadquartersServiceImpl extends ServiceImpl<TbJobGuardianHeadquartersMapper, TbJobGuardianHeadquarters> implements ITbJobGuardianHeadquartersService {

	@Autowired
	private TbJobGuardianHeadquartersMapper tbJobGuardianHeadquartersMapper;
	@Autowired
	private TbJobGuardianCertificateMapper tbJobGuardianCertificateMapper;
	@Autowired
	private TbJobGuardianWorktypeMapper tbJobGuardianWorktypeMapper;
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		tbJobGuardianCertificateMapper.deleteByMainId(id);
		tbJobGuardianWorktypeMapper.deleteByMainId(id);
		tbJobGuardianHeadquartersMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			tbJobGuardianCertificateMapper.deleteByMainId(id.toString());
			tbJobGuardianWorktypeMapper.deleteByMainId(id.toString());
			tbJobGuardianHeadquartersMapper.deleteById(id);
		}
	}

	@Override
	public Page<TbJobGuardianHeadquarters> queryJointPageList(Page<TbJobGuardianHeadquarters> pageList,String username,String orgcode) {
		return tbJobGuardianHeadquartersMapper.queryJointPageList(pageList,username,orgcode);
	}

}
